﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;

namespace QuanLyQuanCaPhe
{
    public partial class frmCreateUsers : Form
    {
        private TaiKhoan taiKhoan;
        public frmCreateUsers(TaiKhoan user)
        {
            InitializeComponent();
            taiKhoan = user;
        }

        private void btnCreateUsers_Click(object sender, EventArgs e)
        {
            if (txtMatKhau.Text == txtMatKhau2.Text)
            {
                string[] para = { "@TenTaiKhoan", "@MatKhau", "@Quyen" };
                string[] values = { txtTenTaiKhoan.Text.Trim(), txtMatKhau.Text.Trim(), cmbChucVu.Text.Trim() };
                int i = connection_sql.Excute("proc_insertTaiKhoan", CommandType.StoredProcedure, para, values, taiKhoan);
                if (i > 0)
                    MessageBox.Show("Tạo tài khoản thành công");
            }
            else
                MessageBox.Show("Mật khẩu không khớp");
        }

        private void txt_ChangeText(object sender, EventArgs e)
        {
            if (txtMatKhau.Text.Trim() != "" && txtMatKhau2.Text.Trim() != "" && txtTenTaiKhoan.Text.Trim() != "" & cmbChucVu.Text.Trim() != "")
                btnCreateUsers.Enabled = true;
            else
                btnCreateUsers.Enabled = false;
        }
    }
}